package com.tang.k.wechatmessage.application.NewsList.presenter.service;

import retrofit2.GsonConverterFactory;
import retrofit2.Retrofit;

/**
 * Retrofit的封装类
 * Created by tangk on 2016/9/12.
 */
public class RetrofitWrapper {

    private static RetrofitWrapper instance;
    private Retrofit retrofit;

    private RetrofitWrapper() {
        retrofit = new Retrofit
                .Builder()
                .baseUrl(Constant.BASE_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
    }

    public static RetrofitWrapper getInstance() {
        if (instance == null) {

            synchronized (RetrofitWrapper.class) {
                if (instance == null) {
                    instance = new RetrofitWrapper();
                }
            }
        }
        return instance;
    }

    public <T> T create(Class<T> service) {
        return retrofit.create(service);
    }

    public class Constant {
        public static final String BASE_URL = "http://v.juhe.cn";
    }
}
